/*
 * Copyright 2011 Subhabrata Ghosh <subho.ghosh at langene.net>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



package net.langene.nlp.model;

//~--- JDK imports ------------------------------------------------------------

import java.util.LinkedList;
import java.util.List;

//~--- classes ----------------------------------------------------------------

/**
 * Enum Represents the Parts-Of-Speech(s) based on the Penn TreeBank
 * Tagging.
 *
 * For more information on Penn TreeBank refer to
 * http://www.cis.upenn.edu/~treebank
 *
 * There are some custom values added to account for punctuation.
 *
 * @author Subhabrata Ghosh <subho.ghosh at langene.net>
 */
public class Token {
    private List<Token>	basewords;
    private int		endOffset;
    private AbstractPOS	pos;
    private int		startOffset;
    private String	word;

    //~--- constructors -------------------------------------------------------

    /**
     * Create an instance of a word.
     *
     * @param word
     */
    public Token(String word) {
        this.word = word;
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the word
     */
    public String getWord() {
        return word;
    }

    /**
     * @return the startOffset
     */
    public int getStartOffset() {
        return startOffset;
    }

    //~--- methods ------------------------------------------------------------

    /**
     * Add a token associated with a base word.
     * 
     * @param tk
     */
    public void addBaseWord(Token tk) {
        if (basewords == null) {
            basewords = new LinkedList<Token>();
        }

        basewords.add(tk);
    }

    //~--- get methods --------------------------------------------------------

    /**
     * Get a list of the base words.
     * 
     * @return
     */
    public List<Token> getBaseWords() {
        return basewords;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param startOffset the startOffset to set
     */
    public void setStartOffset(int startOffset) {
        this.startOffset = startOffset;
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the endOffset
     */
    public int getEndOffset() {
        return endOffset;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param endOffset the endOffset to set
     */
    public void setEndOffset(int endOffset) {
        this.endOffset = endOffset;
    }

    //~--- get methods --------------------------------------------------------

    /**
     * @return the pos
     */
    public AbstractPOS getPos() {
        return pos;
    }

    //~--- set methods --------------------------------------------------------

    /**
     * @param pos the pos to set
     */
    public void setPos(AbstractPOS pos) {
        this.pos = pos;
    }

    //~--- methods ------------------------------------------------------------

    @Override
    public String toString() {
        return "[" + word + "(" + ((pos != null)
                                   ? pos.name()
                                   : "NULL") + ")]";
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
